#!/bin/bash
# stop server
# by yushaolong
# email: yusl@knowbox.cn
# 2018.06.16

if [ ! -f /tmp/census.pid ]; then
    echo "[error]: not found pid file, process may not running."
    exit
fi


kill -USR2 $(cat /tmp/census.pid)

echo "[wait]: now confirm server stop, please wait."
i=1
while [ -f /tmp/census.pid ]; do
    echo "wait $i second..."
    sleep 1
    let i++
done

echo "[success]: server stop success"
